home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 23 / CU Amiga - Super CD-ROM 23 (June 1998).iso / CreatingGames / Utilities / Misc / GMS / GMSDev / Source / Asm / System / RamboWormNasty.s < prev    next >
Encoding:
Text File  |  1997-12-16  |  6.1 KB  |  266 lines

  1. ;-------T-------T------------------------T----------------------------------;
  2. ;Name:      Resource Tracking Demonstration
  3. ;Author:    Paul Manias
  4. ;Copyright: DreamWorld Productions (c) 1996-1997.  Freely distributable.
  5. ;
  6. ;This is the same as the RamboWorm demo but it doesn't free any of its
  7. ;resources!  This would normally crash our machine but the system can
  8. ;recover from such an instance and give back everything that was allocated.
  9. ;
  10. ;If you want proof of how well the resource tracking works, take a memory
  11. ;count before you run the program and then compare the values to the memory
  12. ;you have after running the demo.
  13.  
  14.  
  15.     INCDIR    "GMSDev:Includes/"
  16.     INCLUDE    "dpkernel/dpkernel.i"
  17.  
  18.     SECTION    "Demo",CODE
  19.  
  20. ;===========================================================================;
  21. ;                             INITIALISE DEMO
  22. ;===========================================================================;
  23.  
  24.     STARTDPK
  25.  
  26. Start:    MOVEM.L    A0-A6/D1-D7,-(SP)
  27.     move.l    DPKBase(pc),a6
  28.     lea    BackgroundFile(pc),a0
  29.     moveq    #ID_PICTURE,d0
  30.     CALL    Load
  31.     move.l    d0,PIC_Background
  32.     beq    .Exit
  33.  
  34.     moveq    #ID_SCREEN,d0
  35.     CALL    Get
  36.     move.l    d0,Screen
  37.     beq    .Exit
  38.  
  39.     move.l    PIC_Background(pc),a0
  40.     move.l    PIC_Bitmap(a0),a2
  41.     move.l    Screen(pc),a1
  42.     move.l    #DBLBUFFER,GS_Attrib(a1)
  43.     move.l    BMP_Data(a2),GS_MemPtr1(a1)
  44.     CALL    CopyStructure
  45.  
  46.     move.l    Screen(pc),a0    ;Initialise the screen.
  47.     sub.l    a1,a1
  48.     CALL    Init
  49.     tst.l    d0
  50.     beq.s    .Exit
  51.  
  52.     move.l    BLTBase(pc),a6
  53.     move.l    Screen(pc),a0
  54.     moveq    #BUFFER1,d0
  55.     moveq    #BUFFER2,d1
  56.     CALL    bltCopyBuffer
  57.  
  58. ;---------------------------------------------------------------------------;
  59. ;Initialise the restorelist.
  60.  
  61.     move.l    DPKBase(pc),a6
  62.     lea    RestoreTags(pc),a0
  63.     move.l    Screen(pc),a1    ;a1 = Screen.
  64.     CALL    Init    ;>> = Initialise the restore list.
  65.     tst.l    d0    ;d0 = Check for errors.
  66.     beq.s    .Exit    ;>> = Error, exit.
  67.  
  68. ;---------------------------------------------------------------------------;
  69. ;Load the bob file in.  This contains the graphics data that we are
  70. ;going to draw to the screen.
  71.  
  72.     lea    BBT_Rambo(pc),a0    ;a0 = Object.
  73.     move.l    Screen(pc),a1    ;a1 = Container.
  74.     CALL    Init    ;>> = Initialise bob to screen.
  75.     tst.l    d0
  76.     beq.s    .Exit
  77.  
  78.     lea    SMT_Rambo(pc),a0
  79.     sub.l    a1,a1
  80.     CALL    Init
  81.     tst.l    d0
  82.     beq.s    .Exit
  83.  
  84.     moveq    #ID_JOYDATA,d0    ;Get joydata structure.
  85.     CALL    Get
  86.     move.l    d0,JoyData
  87.     beq.s    .Exit
  88.     move.l    d0,a0    ;Initialise the joydata structure.
  89.     sub.l    a1,a1
  90.     CALL    Init
  91.     tst.l    d0
  92.     beq.s    .Exit
  93.  
  94.     move.l    Screen(pc),a0
  95.     CALL    Display
  96.  
  97.     bsr.s    Main
  98.  
  99. .Exit
  100. ;    move.l    DPKBase(pc),a6
  101. ;    move.l    JoyData(pc),a0    ;Everything that should be freed
  102. ;    CALL    Free    ;has been commented out.  We won't
  103. ;    move.l    SND_Rambo(pc),a0    ;crash though, thanks to resource
  104. ;    CALL    Free    ;tracking.
  105. ;    move.l    BOB_Rambo(pc),a0
  106. ;    CALL    Free
  107. ;    move.l    Restore(pc),a0
  108. ;    CALL    Free
  109. ;    move.l    PIC_Background(pc),a0
  110. ;    CALL    Free
  111. ;    move.l    Screen(pc),a0
  112. ;    CALL    Free
  113.     MOVEM.L    (SP)+,A0-A6/D1-D7
  114.     moveq    #ERR_OK,d0
  115.     rts
  116.  
  117. ;===========================================================================;
  118. ;                                MAIN LOOP
  119. ;===========================================================================;
  120.  
  121. SPEED    =    5
  122. FIRESPEED =    0
  123.  
  124. Main:    moveq    #$00,d7
  125.  
  126. .Loop    move.l    DPKBase(pc),a6
  127.     move.l    Restore(pc),a0    ;a0 = Restore list.
  128.     CALL    Activate    ;>> = Restore the backgrounds.
  129.  
  130.     move.l    BOB_Rambo(pc),a0
  131.     CALL    Draw    ;>> = Blit the bob.
  132.  
  133.     move.l    SCRBase(pc),a6
  134.     CALL    scrWaitAVBL    ;>> = Wait for VBL.
  135.  
  136.     move.l    Screen(pc),a0
  137.     CALL    scrSwapBuffers
  138.  
  139.     addq.w    #1,d7
  140.  
  141.     move.l    DPKBase(pc),a6
  142.     move.l    BOB_Rambo(pc),a1
  143.     tst.b    FireState
  144.     bne.s    .FireOn
  145.  
  146.     cmp.w    #SPEED,d7
  147.     ble.s    .Move
  148.     moveq    #$00,d7
  149.     addq.w    #1,BOB_Frame(a1)
  150.     cmp.w    #9,BOB_Frame(a1)
  151.     blt.s    .Move
  152.     clr.w    BOB_Frame(a1)
  153.     bra.s    .Move
  154.  
  155. .FireOn    cmp.w    #FIRESPEED,d7
  156.     ble.s    .Move
  157.     moveq    #$00,d7
  158.     cmp.w    #10,BOB_Frame(a1)
  159.     bge.s    .On
  160.     move.w    #9,BOB_Frame(a1)
  161.  
  162. .On    addq.w    #1,BOB_Frame(a1)
  163.     cmp.w    #13,BOB_Frame(a1)
  164.     blt.s    .Move
  165.     clr.w    BOB_Frame(a1)
  166.     clr.b    FireState
  167.     move.l    SND_Rambo(pc),a0
  168.     CALL    Activate
  169.  
  170. .Move    move.l    JoyData(pc),a0
  171.     CALL    Query
  172.     move.l    JoyData(pc),a0
  173.     move.l    BOB_Rambo(pc),a1
  174.     move.w    JD_XChange(a0),d0
  175.     add.w    d0,BOB_XCoord(a1)
  176.     move.w    JD_YChange(a0),d0
  177.     add.w    d0,BOB_YCoord(a1)
  178.     move.l    JD_Buttons(a0),d0
  179.     btst    #JB_LMB,d0
  180.     beq.s    .chkRMB
  181.     st    FireState    ;Set fire to on.
  182. .chkRMB    btst    #JB_RMB,d0
  183.     beq    .Loop
  184.     rts
  185.  
  186. FireState:
  187.     dc.b    0
  188.     even
  189.  
  190. ;===========================================================================;
  191. ;                                  DATA
  192. ;===========================================================================;
  193.  
  194. JoyData:    dc.l  0
  195. Screen:        dc.l  0
  196. PIC_Background:    dc.l  0
  197. BackgroundFile:    FILENAME "GMS:demos/data/PIC.Green"
  198.  
  199. ;---------------------------------------------------------------------------;
  200.  
  201. RestoreTags:    dc.l  TAGS_RESTORE
  202. Restore:    dc.l  0
  203.         dc.l  RSA_Entries,1
  204.         dc.l  TAGEND
  205.  
  206. ;---------------------------------------------------------------------------;
  207.  
  208. BBT_Rambo:    dc.l  TAGS_BOB
  209. BOB_Rambo:    dc.l  0
  210.         dc.l  BBA_GfxCoords,.frames
  211.         dc.l  BBA_Width,32
  212.         dc.l  BBA_Height,24
  213.         dc.l  BBA_XCoord,150
  214.         dc.l  BBA_YCoord,150
  215.         dc.l  BBA_ClipLX,32
  216.         dc.l  BBA_ClipRX,320-32
  217.         dc.l  BBA_ClipTY,32
  218.         dc.l  BBA_ClipBY,256-32
  219.         dc.l  BBA_Attrib,BBF_RESTORE|BBF_CLIP|BBF_GENMASKS
  220.         dc.l    BBA_SourceTags,ID_PICTURE
  221.         dc.l    PCA_Source,.file
  222.         dc.l      PCA_BitmapTags,0
  223.         dc.l      BMA_MemType,MEM_BLIT
  224.         dc.l      TAGEND,0
  225.         dc.l    TAGEND,0
  226.         dc.l  TAGEND
  227.  
  228. .frames        dc.w    0,00   ;0 GraphicX / GraphicY
  229.         dc.w   32,00   ;1 ...
  230.         dc.w   64,00   ;2
  231.         dc.w   96,00   ;3
  232.         dc.w  128,00   ;4
  233.         dc.w  160,00   ;5
  234.         dc.w  192,00   ;6
  235.         dc.w  224,00   ;7
  236.         dc.w  256,00   ;8
  237.         dc.w  288,00   ;9
  238.         dc.w    0,48   ;10
  239.         dc.w   32,48   ;11
  240.         dc.w   64,48   ;12
  241.         dc.l  -1
  242.  
  243. .file        FILENAME "GMS:demos/data/PIC.Rambo"
  244.  
  245. ;---------------------------------------------------------------------------;
  246.  
  247. SMT_Rambo:    dc.l  TAGS_SOUND
  248. SND_Rambo:    dc.l  0
  249.         dc.l  SA_Octave,OCT_C2S
  250.         dc.l  SA_Volume,100
  251.         dc.l  SA_Source,.file
  252.         dc.l  SA_Attrib,SSTOPLAST
  253.         dc.l  TAGEND
  254.  
  255. .file        FILENAME "GMS:demos/data/SND.Rambo"
  256.  
  257. ;===========================================================================;
  258.  
  259. ProgName:    dc.b  "Rambo Worm",0
  260. ProgAuthor:    dc.b  "Paul Manias",0
  261. ProgDate:    dc.b  "14 December 1997",0
  262. ProgCopyright:    dc.b  "DreamWorld Productions (c) 1996-1997.  Freely distributable.",0
  263. ProgShort:    dc.b  "Bob demo.",0
  264.         even
  265.  
  266.